<template>
    <div>

        <h2 align="center">注册页面</h2>
        <table class="table table-borderd">
            <tr>
                <td align="right">用户名</td>
                <td><input type="text" v-model="state.UserName" /></td>
            </tr>
            <tr>
                <td align="right">密码</td>
                <td><input type="password" v-model="state.UserPwd"  /></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="button" value="注册" @click="regist" class="btn btn-success" /></td>
            </tr>
        </table>

    </div>
</template>

<script setup lang="ts">
import {reactive,ref,toRefs} from 'vue'
import { useRouter,useRoute } from 'vue-router';
import axios from 'axios';
const router=useRouter();
let data=reactive({
    state:{
        UserName:'',
        UserPwd:''
    }
})
let{state} =toRefs(data);
const regist=()=>{
    axios({
        url:"/api/Users/UserRegist",
        method:'post',
        data:state.value
           
    })
    .then(res=>{
        console.log(res.data.data);
        if(res.data.data>0)
        {
            alert("注册成功");
            router.push("/login");
        }
        else
        {
            alert("注册失败");
        }
    })
   .catch(err=>{
       console.log(err);
   })
}
</script>

<style>

</style>